Setting up an Oracle environment using Windows Docker Desktop
Previously, Oracle provided an image on Docker Hub, but it is no longer available for download. If you want to install Oracle using Docker, you must either use a version provided by others or download the relevant resources from Oracle GitHub to build the image. This article uses the second method.
Prerequisites
- It is currently only provided for Linux Container environments.
- The Windows environment must be able to execute a Linux Bash Shell. You can use the following two methods:
- Use Git Bash.
- Windows 10 has it built-in. Open "Command Prompt" and type
bash. If the command cannot be executed, please refer to this article.
Installation Steps
Download the Dockerfile related files.
Open the file "Location/OracleDatabase/SingleInstance/dockerfile/{version}/Dockerfile" and search for the keyword
INSTALL_FILE_1to see which files need to be installed. If you want to install the XE version, check "Dockerfile.xe".Download the installation files to the version folder. For the download location, please refer to the notes in the Dockerfile. For example:
text# (1) db_home.zip # Download Oracle Database 19c Enterprise Edition or Standard Edition 2 for Linux x64 # from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html #Open bash and change the directory to "Location/OracleDatabase/SingleInstance/dockerfile/".
Enter the command to build the image. The command format is
./buildContainerImage.sh -v [version] -t [image_name:tag] [-e | -s | -x] [-i] [-o] [container build option]. The parameter descriptions are as follows:- -v: Set the version number corresponding to the folder name.
- -t: Set the tag for the docker-image.
- -e: Generate an image for "Enterprise Edition". Requires a version with "Dockerfile" or "Dockerfile.ee".
- -s: Generate an image for "Standard Edition 2". Requires a version with "Dockerfile" or "Dockerfile.se2".
- -x: Generate an image for "Express Edition". Requires a version with "Dockerfile.xe".
- -i: Ignore "MD5 checksums" check.
- -o: Input container build parameters, for example, "'--build-arg SLIMMING=false'".
text./buildContainerImage.sh -e -v 21.3.0 -o '--build-arg SLIMMING=false'Generally, you do not need to use
-o. If you encounter failures due to "MD5 checksums" errors, you can add-i.If an error occurs stating the image does not exist, open "dockerfile{[|.ee|.se2|.xe]}", search for the keyword
FROM oraclelinuxto check the image tag used, then go to Oracle Docker Hub to check if the tag exists. Change it to an existing tag; currently, you should use "7-slim".Wait for the image build to complete; this will take some time.
Create a docker-compose file, referring to the following (please replace the parts in curly braces with your own settings):
textversion: '3.7' services: TP-Oracle: image: oracle/database:{image tag} container_name: TP-Oracle ports: - 1521:1521 - 5500:5500 - 8080:8080 volumes: - {local oradata}:/opt/oracle/oradata - {local scripts/startup}:/opt/oracle/scripts/startup - {local scripts/setup}:/opt/oracle/scripts/setup restart: always environment: - ORACLE_PWD={your password} - ORACLE_CHARACTERSET=AL32UTF8Wait for the container to finish setting up. This takes a long time. If you are unsure when it is finished, you can open "Docker Dashboard" to view the container logs.
Creating Users
- Open a database management tool, such as "Oracle SQL Developer" or "sqlplus". Enter username: SYS, password as set in the docker-compose ORACLE_PWD, and role: sysdba.
- When creating a user, using all uppercase for the username is less likely to cause issues. Passwords are case-sensitive.
- Grant the user "connect", "resource", and "unlimited tablespace". If you have other requirements, you can add other permissions.
- When using version 12c or higher, because there is a distinction between CDB and PDB, if you encounter "ORA-01017 invalid username/password; logon denied" when creating a user, please follow these steps:
- Execute the SQL command
show pdbsto view the PDB name, usually "ORCLPDB1" or "XEPDB1". - Execute the SQL command
ALTER SESSION SET CONTAINER={queried name}to switch the container to the PDB database. - Re-create the user and set role permissions.
- When logging in with the new user, you should use
SERVICE_NAME={PDB Name}instead ofSID={CDB Name}, or modify the "TNSNAMES.ORA" settings.
- Execute the SQL command
Actual Installation Notes
At this stage, installing 11g and 12c XE versions both have folder permission issues, causing the container to fail to run properly. The 19c SE2 version appears to be normal. When the computer or Docker restarts, you may find that newly created users are missing when the Oracle Server first starts. This is because the PDB database mounts slowly; wait a while and they will appear.
Change Log
- 2022-10-24 Initial document creation.